/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package titanisu.basicMathModule1.mixedtpproperfractionVonversion;

import java.util.ArrayList;
import java.util.Random;

/**
 *
 * @author Balaji
 */
public class QuestionGeneratorAddSub {

    ArrayList quest = new ArrayList();

    private void setQ(ArrayList arlst) {
        this.quest = arlst;
    }

    public ArrayList getQuest() {
        return quest;
    }

    public void setQuest(ArrayList quest) {
        this.quest = quest;
    }

    public String getQuestions() {
        /*
         int variables[] = new int[5];
         for (int i = 0; i < variables.length; i++) {
         variables[i] = (new Random()).nextInt(9) + 1;
         }
         */
        int x = (new Random()).nextInt(9) + 1, y = (new Random()).nextInt(9) + 1, z = (new Random()).nextInt(9) + 1;
        String op = "";

        op = "+";
        quest.add(0, "<math>   <mi> " + z + " </mi> <mfrac>       <mi> " + x + " </mi>  <mi> " + y + " </mi>    </mfrac>  </math>  ");

        int[] an = new titanisu.mathUtil.NumberFetcher().simplifyFraction((y * z + x), y);



        if (an[1] != 1) {
        if(an[1] !=y)
            quest.add(1, "" + "<math>   <mfrac>       <mi> " + an[0] + " </mi>  <mi> " + an[1] + " </mi>    </mfrac> <mi> or </mi>  <mfrac>       <mi> " + (y * z + x) + " </mi>  <mi> " + y + " </mi>    </mfrac> </math>  ");
            else
            quest.add(1, "" + "<math>   <mfrac>       <mi> " + an[0] + " </mi>  <mi> " + an[1] + " </mi>    </mfrac>  </math>  ");
            
            
        } else {
        if(an[1] !=y)
            quest.add(1, "" + "<math>    <mi> " + an[0] + " </mi>  <mi>or</mi>  <mfrac>       <mi> " + an[0] + " </mi>  <mi> " + an[1] + " </mi>    </mfrac> <mi> or </mi>  <mfrac>       <mi> " + (y * z + x) + " </mi>  <mi> " + y + " </mi>    </mfrac>  </math>  ");
            else
            quest.add(1, "" + "<math>    <mi> " + an[0] + " </mi>  <mi>or</mi>  <mfrac>       <mi> " + an[0] + " </mi>  <mi> " + an[1] + " </mi>    </mfrac> </math>  ");
        }




        setQ(quest);
        System.out.println(" quest set in questionGenerator is " + quest);
        return (String) quest.get(0);
    }

    /**
     * Gives the answers
     *
     * @return
     */
    public String getAnswer() {
        return (String) quest.get(1);
    }
}
